package com.ease.model.type;

import com.ease.common.enums.EnumUtil;
import com.ease.common.enums.ValuableEnum;

/**
 * 
 * @author nathanleewei
 * 
 */
public enum DataType implements ValuableEnum {

	UNKNOWN((short) 1, "其他"),

	BOOLEAN((short) 10, "布尔"),

	STRING((short) 11, "字符"),

	IPADDRESS((short) 12, "IP地址"),

	SINGLE_DICTIONARY((short) 21, "单选"), // NUMBER(4)

	MULTIPLE_DICTIONARY((short) 22, "多选"), // VARCHAR2(255)

	ENUMERABLE_MODEL((short) 23, "枚举实体"), // NUMBER(9)

	ENUMERABLE_REFERENCE((short) 24, "枚举引用"), // NUMBER(9)

	// value range:-2^7~2^7-1, equal to oracle number(3)
	BYTE((short) 31, "字节"),

	// value range:-2^15~2^15-1, equal to oracle number(5)
	SHORT((short) 32, "短整型"),

	// value range:-2^31~2^31-1, equal to oracle number(10)
	INTEGER((short) 33, "整型"),

	// value range:-2^63~2^63-1, equal to oracle number(19)
	LONG((short) 34, "长整型"),

	FLOAT((short) 41, "单精浮点"),

	DOUBLE((short) 42, "双精浮点"),

	PRECENTAGE((short) 43, "百分比"),

	DATE((short) 51, "日期"),

	DATETIME((short) 52, "日期时间"),

	TIME((short) 53, "时间"),

	BLOB((short) 61, "二进制大对象"),

	CLOB((short) 62, "字符大型对象"),

	RELATIONSHIP((short) 71, "关联关系"), // Reference
	// 区域做成类似于下拉
	LOCATIONRELATIONSHIP((short) 72, "区域关联关系");// 子区域/区域关联做成下拉模式

	private short value;

	private String text;

	private DataType(short value, String text) {
		this.value = value;
		this.text = text;
	}

	public static DataType get(short value) {
		return EnumUtil.get(DataType.class, value, STRING);
	}

	public static DataType get(String name) {
		return EnumUtil.get(DataType.class, name, STRING);
	}

	/**
	 * @return the name
	 */
	public String getText() {
		return text;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name();
	}

	/**
	 * @return the value
	 */
	public short getValue() {
		return value;
	}

}
